
package businesslogic.user;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Locale;

import javax.swing.table.DefaultTableModel;

import businesslogicservice.UserControllerImpli;
import businesslogicservice.userblservice.ChangeMajorBLService;
import businesslogicservice.userblservice.ChangePasswordBLService;
import businesslogicservice.userblservice.SecurityBlService;
import businesslogicservice.userblservice.ShowStudentBLService;
import Enum.Faculty;
import Enum.Period;
import Enum.ResultMessage;
import Enum.Term;
import po.approvepo.LogOffPO;
import po.userpo.Student;
import po.userpo.Teacher;
import po.userpo.UserID;
import po.userpo.UserPO;
import useDatabase.java.getTable;
import vo.approvevo.RequestVo;
import vo.uservo.ChangePasswordVO;
import vo.uservo.LoginVO;
import vo.uservo.RegisterStuVO;
import vo.uservo.ShowStudentVO;

public class UserController extends UnicastRemoteObject implements UserControllerImpli{
    
    public ResultMessage changemajor(RequestVo  requestVo) throws RemoteException{
    	ChangeMajorBLService changeMajor=new ChangeMajor(requestVo);
    	changeMajor.sendRequest();
    	return null;
    }
    
    public UserController() throws RemoteException{
    	
    }
    
    public ResultMessage changepassword(ChangePasswordVO vo) throws RemoteException{
    	ChangePasswordBLService changePassword=new ChangePassword(vo);
    	changePassword.setNewPassword();
    	return null;
    }
    
    public boolean checkPassword(LoginVO vo) throws RemoteException{
    	UserController user;
    	SecurityBlService security=new Security(vo);
    	return security.checkPassword();
    }
    
    public ArrayList<Student> showstudent(ShowStudentVO showstudentvo) throws RemoteException{
    	UserController user;
    	ShowStudentBLService show=new ShowStudent(showstudentvo);
    	return show.getstudent(showstudentvo);
    }
    
	@Override
	 public ResultMessage register(RequestVo vo,ArrayList<RegisterStuVO> list) throws RemoteException{
		Register register=new Register(vo,list);
		register.register();
		return ResultMessage.succeed;
	}

	@Override
	public UserPO getUser(UserID userID) throws RemoteException {
		// TODO Auto-generated method stub
		GetUserByID getUserByID=new GetUserByID(userID);
		return getUserByID.getUser();
	}

	public ResultMessage logOff(RequestVo   vo,ArrayList<LogOffPO> list) throws RemoteException {
		// TODO Auto-generated method stub
		LogOff logOff=new LogOff(vo,list);
		logOff.logOff();
		return null;
	}

	@Override
	public ArrayList<RegisterStuVO> getRegisterList(Faculty f ,  String appliID) throws RemoteException {
		GetRegisterList getList = new GetRegisterList();
		return getList.list(f, appliID);
	}
	
	 public  ArrayList<LogOffPO> getLogOffList(Faculty f , String appliID) throws RemoteException{
		 GetLogOffList getLogOffList=new GetLogOffList();
		return getLogOffList.list(f, appliID);
	 }
	

	public boolean CheckPeriod(Period period) throws RemoteException {
		CheckPeriod checkPeriod=new CheckPeriod(period);
		boolean ifOK=checkPeriod.ifOk();
		return true;
	}

	@Override
	public ArrayList<Teacher> getTchList(Faculty f) throws RemoteException {
		GetTeacherList getList = new GetTeacherList();
		return getList.list(f);
	}

	@Override
	public Term getTerm(int registerTime) throws RemoteException {
		return GetTermByRegisterTime.term(registerTime);
	}
	
	
    
}